import {submitFormData, submitJsonData, submitMultipartFormData} from "../../../../../../redare/utils/Request";

/**
 * Created by RdevPlugins.JsPresenterBuilderAction on 2020-03-07 13:02:40.
 */

/**
 * @param body: {roleId, funIds, platform, userPlatform}
 * @param query: {}
 * @returns Promise
 */
export function addRoleFun(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/permission/rolefun/add',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {roleId, menuIds, platform, userPlatform}
 * @param query: {}
 * @returns Promise
 */
export function addRoleMenu(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/permission/rolemenu/add',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {roleId, funIds, platform, userPlatform}
 * @param query: {}
 * @returns Promise
 */
export function delRoleFun(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/permission/rolefun/del',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {roleId, menuIds, platform, userPlatform}
 * @param query: {}
 * @returns Promise
 */
export function delRoleMenu(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/permission/rolemenu/del',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {roleId, componentId, id, module, classifyName, classifyNameLevel, key, platform, userPlatform}
 * @param query: {curPage,pageSize}
 * @returns Promise
 */
export function findRoleFunPage(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/permission/rolefun/page',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {roleId, menuId, id, module, classifyName, classifyNameLevel, key, platform, userPlatform}
 * @param query: {returnAll,curPage,pageSize}
 * @returns Promise
 */
export function findRoleFunList(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/permission/rolefun/list',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {roleId, menuId, platformMenuId, parentMenuId, enabled, excRoot, sortToTree, levelTreeQuery, platform}
 * @param query: {curPage,pageSize}
 * @returns Promise
 */
export function findRoleMenuPage(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/permission/rolemenu/page',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {roleId, menuId, platformMenuId, parentMenuId, enabled, excRoot, sortToTree, levelTreeQuery, platform}
 * @param query: {returnAll,curPage,pageSize}
 * @returns Promise
 */
export function findRoleMenuList(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/permission/rolemenu/list',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

